<!DOCTYPE html><html lang="zh-CN" data-theme="dark"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>J.のblog</title><meta name="author" content="J."><meta name="copyright" content="J."><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#0d0d0d"><meta property="og:type" content="website">
<meta property="og:title" content="J.のblog">
<meta property="og:url" content="http://dycloudnavite.love/page/2/index.html">
<meta property="og:site_name" content="J.のblog">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://dycloudnavite.love/img/touxiang.png">
<meta property="article:author" content="J.">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://dycloudnavite.love/img/touxiang.png"><link rel="shortcut icon" href="/dujie5416/img/touxiang.png"><link rel="canonical" href="http://dycloudnavite.love/page/2/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/dujie5416/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/dujie5416/',
  algolia: {"appId":"9GWB2VV7GN","apiKey":"dac56ec5b0b1f45281251ee59db4d637","indexName":"blog","hits":{"per_page":6},"languages":{"input_placeholder":"搜索文章","hits_empty":"找不到您查询的内容：${query}","hits_stats":"找到 ${hits} 条结果，用时 ${time} 毫秒"}},
  localSearch: undefined,
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'J.のblog',
  isPost: false,
  isHome: true,
  isHighlightShrink: false,
  isToc: false,
  postUpdate: '2024-01-30 11:12:40'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/xxx.css"><link rel="stylesheet" href="/css/universe.css"><link rel="stylesheet" href="/css/custom.css"><style type="text/css">#toggle-sidebar {bottom: 80px}</style><link rel="stylesheet" href="https://fastly.jsdelivr.net/gh/tzy13755126023/BLOG_SOURCE/css/function.min.css"><link rel="stylesheet" href="/css/rightMenu.css"><style type="text/css">#toggle-sidebar {left:100px}</style><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/clock.min.css" /><!-- hexo injector head_end end --><meta name="generator" content="Hexo 6.2.0"><link rel="alternate" href="/dujie5416/atom.xml" title="J.のblog" type="application/atom+xml">
</head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/dujie5416/img/touxiang.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/dujie5416/archives/"><div class="headline">文章</div><div class="length-num">73</div></a><a href="/dujie5416/tags/"><div class="headline">标签</div><div class="length-num">17</div></a><a href="/dujie5416/categories/"><div class="headline">分类</div><div class="length-num">11</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/dujie5416/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/dujie5416/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/dujie5416/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/dujie5416/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div></div></div></div><div class="page" id="body-wrap"><header class="full_page" id="page-header" style="background-image: url('/dujie5416/img/longzhu.png')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/dujie5416/">J.のblog</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/dujie5416/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/dujie5416/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/dujie5416/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/dujie5416/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="site-info"><h1 id="site-title">J.のblog</h1><div id="site-subtitle"><span id="subtitle"></span></div></div><div id="scroll-down"><i class="fas fa-angle-down scroll-down-effects"></i></div></header><main class="layout" id="content-inner"><div class="recent-posts" id="recent-posts"><div class="recent-post-item"><div class="post_cover left"><a href="/dujie5416/2023/05/10/%E8%BF%9B%E7%A8%8B%E7%BA%BF%E7%A8%8B/" title="进程和线程"><img class="post_bg" src="/dujie5416/img/golang.png" onerror="this.onerror=null;this.src='/dujie5416/img/404.jpg'" alt="进程和线程"></a></div><div class="recent-post-info"><a class="article-title" href="/dujie5416/2023/05/10/%E8%BF%9B%E7%A8%8B%E7%BA%BF%E7%A8%8B/" title="进程和线程">进程和线程</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-05-10T06:32:00.000Z" title="发表于 2023-05-10 14:32:00">2023-05-10</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/dujie5416/categories/golang/">golang</a></span></div><div class="content">进程线程并发和并行并发Concurrency： 是指同一时刻在CPU中只能有一条指令执行，多个进程指令被快速的轮换执行。从宏观来看，是多个进程同时执行。但从微观来看，这些进程并不是同时执行的，只是吧时间分成若干段，多个进程快速交替的执行。
在操作系统中，进程的并发就是：CPU把一个时间段划分成几个时间片，进程在这几个时间区间之间来回切换处理的过程。CPU处理的速度非常快，只要时间间隔处理得当，就可以让用户感觉是多个进程同时在执行。如下图

并行parallelism：同一时刻有多条执行在多个处理器上同时执行。如果系统有一个以上CPU，当一个CPU在执行一个进程时，另一个CPU可以执行另一个进程，两个进程互不抢占cpu资源，可以同时进行。
决定进程并行的因素不是CPU数量，而是CPU的核心数。比如一个CPU多核也可以并行

进程和线程早期工作模式最早计算机很巨大笨重，得把程序转换成某种编码对应的纸带或卡片上的孔（类似2B铅笔涂答题卡），输入设备再读取打孔纸带把程序和数据装入计算机，程序在计算机上运行完，在通过打印机输出。整个过程一个程序从输入到输出在所有环节都是独占资源，实际上输入、输出 ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/dujie5416/2023/05/09/Go%E6%93%8D%E4%BD%9CMongoDB/" title="Golang 操作MongoDB"><img class="post_bg" src="/dujie5416/img/golang.png" onerror="this.onerror=null;this.src='/dujie5416/img/404.jpg'" alt="Golang 操作MongoDB"></a></div><div class="recent-post-info"><a class="article-title" href="/dujie5416/2023/05/09/Go%E6%93%8D%E4%BD%9CMongoDB/" title="Golang 操作MongoDB">Golang 操作MongoDB</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-05-09T06:32:00.000Z" title="发表于 2023-05-09 14:32:00">2023-05-09</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/dujie5416/categories/golang/">golang</a></span></div><div class="content">MongoDBMongoDB属于非关系型数据库，是由C++编写的分布式文档数据库。内部使用类似于Json的bson二进制格式。
中文手册
https://www.w3cschool.cn/mongodb/
安装https://www.mongodb.com/try/download/community
自行下载对应操作系统的MongoDB，并运行它。
windows可以下载官方zip，解压即可使用。



组件
文件名



Server
mongod.exe


Router
mongos.exe，Query Router,Sharding Cluster


Client
mongo.exe


MonitoringTools
mongostat.exe，mongotop.exe


ImportExportTools
mongostat.exe，mongotop.exe


MiscellaneousTools
bsondump.exe，mongofiles.exe，mongooplog.exe，mongoperf.exe


运行$ cd /o/mongodb3.6/bin
$ ...</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/dujie5416/2023/05/06/Golang%E4%B8%AD%E7%9A%84GORM/" title="Golang GORM使用"><img class="post_bg" src="/dujie5416/img/golang.png" onerror="this.onerror=null;this.src='/dujie5416/img/404.jpg'" alt="Golang GORM使用"></a></div><div class="recent-post-info"><a class="article-title" href="/dujie5416/2023/05/06/Golang%E4%B8%AD%E7%9A%84GORM/" title="Golang GORM使用">Golang GORM使用</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-05-06T06:32:00.000Z" title="发表于 2023-05-06 14:32:00">2023-05-06</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/dujie5416/categories/golang/">golang</a></span></div><div class="content">GORMSQLBuilderSQLBuilder是一个用于生成SQL语句的库。
项目地址：

https://gitee.com/iRainIoT/go-sqlbuilder、https://github.com/parkingwang/go-sqlbuilder
目前已支持MySQL基本Select&#x2F;Update&#x2F;Insert&#x2F;Delete&#x2F;Where 等语法
目前只支持MySQL语法
未支持多表查询
 go get -u github.com/parkingwang/go-sqlbuilder


https://github.com/huandu/go-sqlbuilder，功能更强
go get github.com/huandu/go-sqlbuilder 



package main
import (
 "database/sql"
 "fmt"
 "log"
 _ "github.com/go-sql-driver/mysql"
 "github.com/huandu/go-sqlbuilder"
)
var db *sql.D ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/dujie5416/2023/05/03/Golang%E6%95%B0%E6%8D%AE%E5%BA%93%E6%A0%87%E5%87%86%E5%BC%80%E5%8F%91/" title="Golang 数据库标准开发"><img class="post_bg" src="/dujie5416/img/golang.png" onerror="this.onerror=null;this.src='/dujie5416/img/404.jpg'" alt="Golang 数据库标准开发"></a></div><div class="recent-post-info"><a class="article-title" href="/dujie5416/2023/05/03/Golang%E6%95%B0%E6%8D%AE%E5%BA%93%E6%A0%87%E5%87%86%E5%BC%80%E5%8F%91/" title="Golang 数据库标准开发">Golang 数据库标准开发</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-05-03T06:32:00.000Z" title="发表于 2023-05-03 14:32:00">2023-05-03</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/dujie5416/categories/golang/">golang</a></span></div><div class="content">数据库标准开发驱动连接数据库是典型的CS变成，服务器端被动等待客户端建立TCP连接，并在此连接上进行特定的应用层协议。但是一般用户并不需要了解这些细节，这些都被打包到了驱动库中，只需要简单的调用打开就可以指定协议连接到指定的数据库中
数据库的种类和产品太多，协议太多，Go官方很难提供针对不同数据库的驱动程序，往往由各数据库官方或第三方给出不同开发语言的驱动库。但是，为了Go语言可以提前定义操作一个数据库的所有行为（接口）和数据（结构体）的规范，这些定义在databasq&#x2F;sql下。
mysql驱动：

https://github.com/go-sql-driver/mysql 支持database&#x2F;sql，推荐
https://github.com/ziutek/mymysql 支持database&#x2F;sql，支持自定义接口
https://github.com/Philio/GoMySQL 不支持database&#x2F;sql，支持自定义接口

安装mysql的驱动
$ go get -u github.com/go-sql-driver/mysql ...</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/dujie5416/2023/05/01/Golang%E6%97%A5%E5%BF%97%E7%AE%A1%E7%90%86/" title="Golang日志管理"><img class="post_bg" src="/dujie5416/img/golang.png" onerror="this.onerror=null;this.src='/dujie5416/img/404.jpg'" alt="Golang日志管理"></a></div><div class="recent-post-info"><a class="article-title" href="/dujie5416/2023/05/01/Golang%E6%97%A5%E5%BF%97%E7%AE%A1%E7%90%86/" title="Golang日志管理">Golang日志管理</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-05-01T06:32:00.000Z" title="发表于 2023-05-01 14:32:00">2023-05-01</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/dujie5416/categories/golang/">golang</a></span></div><div class="content">日志标准库的log包Go标准库中有log包，提供了简单的日志功能。



输出
格式输出
换行输出




log.Print()
log.Printf()
log.Pringln()
类似fmt.print*


log.Fatal()
log.Fatalf()
log.Fatalln()
相当于log.Print* + os.Exit(1)


log.Panic()
log.Panicf()
log.Panicln()
相当于log.Print* + panic(0


日志输出需要使用日志记录器Logger。
log包提供了一个缺省的Logger即std。std是小写的，包外不可见，所以提供了Default()方法返回std给包外使用。如下：
package main

import (
	"log"
)

func main() &#123;
        // 这里就是使用缺省的logger对象，可以点进Println查看源码
	log.Println("这是缺省的logger")
&#125;

源码如下：
// go源码
// Println calls Output ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/dujie5416/2023/04/25/golang%E5%8C%85%E7%AE%A1%E7%90%86/" title="Golang包管理"><img class="post_bg" src="/dujie5416/img/golang.png" onerror="this.onerror=null;this.src='/dujie5416/img/404.jpg'" alt="Golang包管理"></a></div><div class="recent-post-info"><a class="article-title" href="/dujie5416/2023/04/25/golang%E5%8C%85%E7%AE%A1%E7%90%86/" title="Golang包管理">Golang包管理</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-04-25T06:32:00.000Z" title="发表于 2023-04-25 14:32:00">2023-04-25</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/dujie5416/categories/golang/">golang</a></span></div><div class="content">包管理模块化用任何语言来开发，如果软件规模扩大，会编写大量的函数、结构体、接口等代码。这些代码不可能写在一个文件中，这就会产生大量的文件。如果这些文件杂乱无章，就会造成名称冲突、重复定义、难以检索、无法引用、共享不便、版本管理等一系列问题。有一些功能模块如何复用，如何共享方便其他项目使用。所以，一定要有模块化管理，解决以上诸多问题。
包
包由多个文件和目录组成
使用package&lt;包名&gt; 来定义包名
包名一般采用小写，符合标识符要求
当前目录名和package&lt;包名&gt; 中的包名不需要一致，但最好保持一致
同级文件归属一个包，就是说每个包目录中，只能统一使用同一个package的包名，否则编译出错

一般来说，开发项目时，可以吧相关功能的代码集中放在某几个包里面。例如在main包目录中新建一个calc包，将所有计算函数都放在其中，以供别的代码调用。
同一个目录就是同一个包，该包内go文件里面的变量、函数、结构体互相可见，可以直接调用。
跨目录就是跨包，使用时需要导入别的包，导入需要指定该包的路径，
包管理GOPATHGo 1.11版本之前，项目依赖包存于GOPAT ...</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/dujie5416/2023/04/22/Golang%E6%97%B6%E9%97%B4/" title="Golang时间操作"><img class="post_bg" src="/dujie5416/img/golang.png" onerror="this.onerror=null;this.src='/dujie5416/img/404.jpg'" alt="Golang时间操作"></a></div><div class="recent-post-info"><a class="article-title" href="/dujie5416/2023/04/22/Golang%E6%97%B6%E9%97%B4/" title="Golang时间操作">Golang时间操作</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-04-22T06:32:00.000Z" title="发表于 2023-04-22 14:32:00">2023-04-22</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/dujie5416/categories/golang/">golang</a></span></div><div class="content">时间在Go语言中，时间定义为Time结构体。 
var t = time.Now()
fmt.Printf("%T\n", t) // time.Time
fmt.Printf("%v %+[1]v\n", t) // 2022-10-06 19:35:00.1963422 +0800 CST m=+0.001534601
fmt.Printf("%#v\n", t) // time.Date(2022, time.October, 6, 19, 35, 0, 
196342200, time.Local)
fmt.Printf("%T, %[1]v\n", t.UTC()) // UTC时间
// time.Time, 2022-10-06 11:35:00.1963422 +0000 UTC
m&#x3D;+0.001530201为单调时间，利用的是晶体振荡器的间隔时间，很多时间函数计算都舍弃了它。如果不是非常精准的时间间隔计算，请忽略它。
时间格式化var t = time.Now()
fmt.Printf("%T, %[1]v\n", t)
fmt.Println(t.Form ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/dujie5416/2023/04/21/Golang%E5%BA%8F%E5%88%97%E5%8C%96%E5%92%8C%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96/" title="Golang序列化和反序列化"><img class="post_bg" src="/dujie5416/img/golang.png" onerror="this.onerror=null;this.src='/dujie5416/img/404.jpg'" alt="Golang序列化和反序列化"></a></div><div class="recent-post-info"><a class="article-title" href="/dujie5416/2023/04/21/Golang%E5%BA%8F%E5%88%97%E5%8C%96%E5%92%8C%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96/" title="Golang序列化和反序列化">Golang序列化和反序列化</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-04-21T06:32:00.000Z" title="发表于 2023-04-21 14:32:00">2023-04-21</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/dujie5416/categories/golang/">golang</a></span></div><div class="content">序列化和反序列化内存中的map、slice、array以及各种对象，如何保存到一个文件中？ 如果是自己定义的结构体的实例，如何保存到一个文件中？
如何从文件中读取数据，并让它们在内存中再次恢复成自己对应的类型的实例？要设计一套协议，按照某种规则，把内存中数据保存到文件中。文件是一个字节序列，所以必须把数据转换成字节序列，输出到文件。这就是序列化。 反之，从文件的字节序列恢复到内存并且还是原来的类型，就是反序列化。
序列化：将内存中的数据结构转换成字节序列
反序列化：将字节序列恢复到内存中并且还是之前的数据类型，就是反序列化
定义
serialization序列化：将内存中对象存储下来，把他变成一个个字节。转为二进制数据
deserialization反序列化：将文件的一个个字节恢复成内存中对象。从二进制数据中恢复。

序列化保存到文件就是持久化。
可以将数据序列化后持久化，或者网络传输；也可以将从文件中或网络中接收到的字节序列反序列化。
可以把数据和二进制序列之间的相互转换称为二进制序列化、反序列化，把数字和字符序列之间的相互转换称为字符序列化、反序列化
字符序列化：JSON、XML等 ...</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/dujie5416/2023/04/20/Go%E4%B8%AD%E7%9A%84%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1/" title="Go中的面向对象"><img class="post_bg" src="/dujie5416/img/golang.png" onerror="this.onerror=null;this.src='/dujie5416/img/404.jpg'" alt="Go中的面向对象"></a></div><div class="recent-post-info"><a class="article-title" href="/dujie5416/2023/04/20/Go%E4%B8%AD%E7%9A%84%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1/" title="Go中的面向对象">Go中的面向对象</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-04-20T06:32:00.000Z" title="发表于 2023-04-20 14:32:00">2023-04-20</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/dujie5416/categories/golang/">golang</a></span></div><div class="content">Go中的面向对象面相对象三要素
封装：将属性（数据）和方法（操作）封装，提供访问控制，隐藏实现细节，暴露该暴露的
继承：子类可以从父类直接获得属性和方法，减少重复定义。子类中如果与父类不同，可以自己定义新的属性和方法，也可以覆盖同名的属性和方法
多态：前提是继承和覆盖，使得子类中虽然使用同一个方法，但是不同子类表现不同，就是不同的态

实现了以上特征的语言，才能称为面向对象编程范式语言。
严格意义上说，Go语言不想实现面向对象编程范式。但是面相对象又有一些不错的特征，Go语言通过组合的方式实现了类似的功能。
只能说，Go语言实现了一种非常有自我特征的面向对象。
封装通过结构体，可以把数据字段封装在内，还可以为结构体提供方法。
访问控制：

属性、方法标识符首字母大写，实现了对包外可见的访问控制
属性、方法标识符首字母小写，仅包内可见
这些一定程度上实现了public、private的访问控制。

构造函数Go没有提供类似C++、Java一样的构造函数、析构函数。在Go中，用构造结构体实例的函数，这个函数没有特别的要求，只要返回结构体实例或其指针即可（建议返回指针，不然返回值会拷贝）。习 ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/dujie5416/2023/04/19/Golang%E9%94%99%E8%AF%AF%E5%A4%84%E7%90%86/" title="Golang错误处理"><img class="post_bg" src="/dujie5416/img/golang.png" onerror="this.onerror=null;this.src='/dujie5416/img/404.jpg'" alt="Golang错误处理"></a></div><div class="recent-post-info"><a class="article-title" href="/dujie5416/2023/04/19/Golang%E9%94%99%E8%AF%AF%E5%A4%84%E7%90%86/" title="Golang错误处理">Golang错误处理</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2023-04-19T06:32:00.000Z" title="发表于 2023-04-19 14:32:00">2023-04-19</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/dujie5416/categories/golang/">golang</a></span></div><div class="content">错误处理异常处理Go的设计者认为其它语言异常处理太过消耗资源，且设计和处理复杂，导致使用者不能很好的处理错误，甚至觉得异常和错误处理起来麻烦而忽视、忽略掉，从而导致程序崩溃。

函数调用，返回值可以返回多值，一般最后一个值可以是error接口类型的值
如果函数调用产生错误，则这个值是一个error接口类型的错误
如果函数调用成功，则该值是nil


检查函数返回值中的错误是否是nil，如果不是nil，进行必要的错误处理

error是Go中声明的接口类型
type error interface&#123;
    Error() string

&#125;
所有实现Error() string签名的方法，都可以实现错误接口。用Error()方法返回错误的具体描述
自定义errorpackage main
import "fmt"
type errorString struct &#123;
 s string
&#125;
func (e *errorString) Error() string &#123;
 return e.s &#125;
func New(text str ...</div></div></div><nav id="pagination"><div class="pagination"><a class="extend prev" rel="prev" href="/dujie5416/"><i class="fas fa-chevron-left fa-fw"></i></a><a class="page-number" href="/dujie5416/">1</a><span class="page-number current">2</span><a class="page-number" href="/dujie5416/page/3/#content-inner">3</a><span class="space">&hellip;</span><a class="page-number" href="/dujie5416/page/8/#content-inner">8</a><a class="extend next" rel="next" href="/dujie5416/page/3/#content-inner"><i class="fas fa-chevron-right fa-fw"></i></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/dujie5416/img/touxiang.png" onerror="this.onerror=null;this.src='/dujie5416/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">J.</div><div class="author-info__description"></div></div><div class="card-info-data site-data is-center"><a href="/dujie5416/archives/"><div class="headline">文章</div><div class="length-num">73</div></a><a href="/dujie5416/tags/"><div class="headline">标签</div><div class="length-num">17</div></a><a href="/dujie5416/categories/"><div class="headline">分类</div><div class="length-num">11</div></a></div></div><div class="sticky_layout"><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/dujie5416/2023/07/29/%E6%A0%B9%E6%8D%AErouter%E6%98%BE%E7%A4%BA%E5%B7%A6%E4%BE%A7%E8%8F%9C%E5%8D%95%E6%A0%8F%E9%9A%90%E8%97%8F%E6%9F%90%E4%B8%AA%E8%8F%9C%E5%8D%95%E9%80%89%E9%A1%B9/" title="vue3左侧菜单隐藏某选项"><img src="/dujie5416/img/golang.png" onerror="this.onerror=null;this.src='/dujie5416/img/404.jpg'" alt="vue3左侧菜单隐藏某选项"/></a><div class="content"><a class="title" href="/dujie5416/2023/07/29/%E6%A0%B9%E6%8D%AErouter%E6%98%BE%E7%A4%BA%E5%B7%A6%E4%BE%A7%E8%8F%9C%E5%8D%95%E6%A0%8F%E9%9A%90%E8%97%8F%E6%9F%90%E4%B8%AA%E8%8F%9C%E5%8D%95%E9%80%89%E9%A1%B9/" title="vue3左侧菜单隐藏某选项">vue3左侧菜单隐藏某选项</a><time datetime="2023-07-29T06:32:00.000Z" title="发表于 2023-07-29 14:32:00">2023-07-29</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/dujie5416/2023/07/13/Vue%E7%8A%B6%E6%80%81%E7%AE%A1%E7%90%86/" title="Vue状态管理"><img src="/dujie5416/img/golang.png" onerror="this.onerror=null;this.src='/dujie5416/img/404.jpg'" alt="Vue状态管理"/></a><div class="content"><a class="title" href="/dujie5416/2023/07/13/Vue%E7%8A%B6%E6%80%81%E7%AE%A1%E7%90%86/" title="Vue状态管理">Vue状态管理</a><time datetime="2023-07-13T09:29:00.000Z" title="发表于 2023-07-13 17:29:00">2023-07-13</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/dujie5416/2023/06/27/%E5%9F%BA%E4%BA%8EIOC%E8%A7%A3%E5%86%B3%E5%AF%B9%E8%B1%A1%E4%BE%9D%E8%B5%96%E9%97%AE%E9%A2%98/" title="基于IOC解决对象依赖问题"><img src="/dujie5416/img/golang.png" onerror="this.onerror=null;this.src='/dujie5416/img/404.jpg'" alt="基于IOC解决对象依赖问题"/></a><div class="content"><a class="title" href="/dujie5416/2023/06/27/%E5%9F%BA%E4%BA%8EIOC%E8%A7%A3%E5%86%B3%E5%AF%B9%E8%B1%A1%E4%BE%9D%E8%B5%96%E9%97%AE%E9%A2%98/" title="基于IOC解决对象依赖问题">基于IOC解决对象依赖问题</a><time datetime="2023-06-27T03:32:00.000Z" title="发表于 2023-06-27 11:32:00">2023-06-27</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/dujie5416/2023/06/23/Gin%E6%A1%86%E6%9E%B6/" title="Gin框架"><img src="/dujie5416/img/golang.png" onerror="this.onerror=null;this.src='/dujie5416/img/404.jpg'" alt="Gin框架"/></a><div class="content"><a class="title" href="/dujie5416/2023/06/23/Gin%E6%A1%86%E6%9E%B6/" title="Gin框架">Gin框架</a><time datetime="2023-06-23T06:32:00.000Z" title="发表于 2023-06-23 14:32:00">2023-06-23</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/dujie5416/2023/06/04/ServeMux%E3%80%81httprouter/" title="ServeMux、httprouter"><img src="/dujie5416/img/golang.png" onerror="this.onerror=null;this.src='/dujie5416/img/404.jpg'" alt="ServeMux、httprouter"/></a><div class="content"><a class="title" href="/dujie5416/2023/06/04/ServeMux%E3%80%81httprouter/" title="ServeMux、httprouter">ServeMux、httprouter</a><time datetime="2023-06-04T03:32:00.000Z" title="发表于 2023-06-04 11:32:00">2023-06-04</time></div></div></div></div><div class="card-widget card-categories"><div class="item-headline">
            <i class="fas fa-folder-open"></i>
            <span>分类</span>
            <a class="card-more-btn" href="/dujie5416/categories/" title="查看更多">
    <i class="fas fa-angle-right"></i></a>
            </div>
            <ul class="card-category-list" id="aside-cat-list">
            <li class="card-category-list-item "><a class="card-category-list-link" href="/dujie5416/categories/Django/"><span class="card-category-list-name">Django</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/dujie5416/categories/Docker/"><span class="card-category-list-name">Docker</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/dujie5416/categories/SonarQube/"><span class="card-category-list-name">SonarQube</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/dujie5416/categories/golang/"><span class="card-category-list-name">golang</span><span class="card-category-list-count">30</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/dujie5416/categories/iptables/"><span class="card-category-list-name">iptables</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/dujie5416/categories/jenkins/"><span class="card-category-list-name">jenkins</span><span class="card-category-list-count">2</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/dujie5416/categories/kubernetes/"><span class="card-category-list-name">kubernetes</span><span class="card-category-list-count">18</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/dujie5416/categories/linux/"><span class="card-category-list-name">linux</span><span class="card-category-list-count">7</span></a></li>
            </ul></div><div class="card-widget card-tags"><div class="item-headline"><i class="fas fa-tags"></i><span>标签</span></div><div class="card-tag-cloud"><a href="/dujie5416/tags/Django/" style="font-size: 1.1em; color: #999">Django</a> <a href="/dujie5416/tags/Python/" style="font-size: 1.1em; color: #999">Python</a> <a href="/dujie5416/tags/SonarQube/" style="font-size: 1.1em; color: #999">SonarQube</a> <a href="/dujie5416/tags/centos/" style="font-size: 1.23em; color: #999ea6">centos</a> <a href="/dujie5416/tags/docker/" style="font-size: 1.1em; color: #999">docker</a> <a href="/dujie5416/tags/golang/" style="font-size: 1.43em; color: #99a6b9">golang</a> <a href="/dujie5416/tags/grafana/" style="font-size: 1.1em; color: #999">grafana</a> <a href="/dujie5416/tags/iptables/" style="font-size: 1.1em; color: #999">iptables</a> <a href="/dujie5416/tags/jenkins/" style="font-size: 1.17em; color: #999c9f">jenkins</a> <a href="/dujie5416/tags/kubernetes/" style="font-size: 1.37em; color: #99a4b2">kubernetes</a> <a href="/dujie5416/tags/linux/" style="font-size: 1.23em; color: #999ea6">linux</a> <a href="/dujie5416/tags/mysql/" style="font-size: 1.3em; color: #99a1ac">mysql</a> <a href="/dujie5416/tags/prometheus/" style="font-size: 1.1em; color: #999">prometheus</a> <a href="/dujie5416/tags/python/" style="font-size: 1.1em; color: #999">python</a> <a href="/dujie5416/tags/svn/" style="font-size: 1.1em; color: #999">svn</a> <a href="/dujie5416/tags/%E4%BA%91%E5%8E%9F%E7%94%9F/" style="font-size: 1.5em; color: #99a9bf">云原生</a> <a href="/dujie5416/tags/%E9%98%BF%E9%87%8C%E4%BA%91/" style="font-size: 1.1em; color: #999">阿里云</a></div></div><div class="card-widget card-archives"><div class="item-headline"><i class="fas fa-archive"></i><span>归档</span><a class="card-more-btn" href="/dujie5416/archives/" title="查看更多">
    <i class="fas fa-angle-right"></i></a></div><ul class="card-archive-list"><li class="card-archive-list-item"><a class="card-archive-list-link" href="/dujie5416/archives/2023/07/"><span class="card-archive-list-date">七月 2023</span><span class="card-archive-list-count">2</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/dujie5416/archives/2023/06/"><span class="card-archive-list-date">六月 2023</span><span class="card-archive-list-count">4</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/dujie5416/archives/2023/05/"><span class="card-archive-list-date">五月 2023</span><span class="card-archive-list-count">9</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/dujie5416/archives/2023/04/"><span class="card-archive-list-date">四月 2023</span><span class="card-archive-list-count">12</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/dujie5416/archives/2023/02/"><span class="card-archive-list-date">二月 2023</span><span class="card-archive-list-count">4</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/dujie5416/archives/2023/01/"><span class="card-archive-list-date">一月 2023</span><span class="card-archive-list-count">1</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/dujie5416/archives/2022/08/"><span class="card-archive-list-date">八月 2022</span><span class="card-archive-list-count">8</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/dujie5416/archives/2022/07/"><span class="card-archive-list-date">七月 2022</span><span class="card-archive-list-count">9</span></a></li></ul></div><div class="card-widget card-webinfo"><div class="item-headline"><i class="fas fa-chart-line"></i><span>网站资讯</span></div><div class="webinfo"><div class="webinfo-item"><div class="item-name">文章数目 :</div><div class="item-count">73</div></div><div class="webinfo-item"><div class="item-name">已运行时间 :</div><div class="item-count" id="runtimeshow" data-publishDate="2019-09-04T16:00:00.000Z"><i class="fa-solid fa-spinner fa-spin"></i></div></div><div class="webinfo-item"><div class="item-name">本站访客数 :</div><div class="item-count" id="busuanzi_value_site_uv"><i class="fa-solid fa-spinner fa-spin"></i></div></div><div class="webinfo-item"><div class="item-name">本站总访问量 :</div><div class="item-count" id="busuanzi_value_site_pv"><i class="fa-solid fa-spinner fa-spin"></i></div></div><div class="webinfo-item"><div class="item-name">最后更新时间 :</div><div class="item-count" id="last-push-date" data-lastPushDate="2024-01-30T03:12:39.963Z"><i class="fa-solid fa-spinner fa-spin"></i></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('/dujie5416/img/longzhu.png')"><div id="footer-wrap"><div class="copyright">&copy;2019 - 2024  <i id="heartbeat" class="fa fas fa-heartbeat"></i> J.</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a><a href="http://beian.miit.gov.cn/"  style="color:#f72b07" target="_blank">京ICP备2022023567号</a></div></div><link rel="stylesheet" href="https://fastly.jsdelivr.net/gh/HCLonely/images@master/others/heartbeat.min.css"></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="algolia-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="search-wrap"><div id="algolia-search-input"></div><hr/><div id="algolia-search-results"><div id="algolia-hits"></div><div id="algolia-pagination"></div><div id="algolia-info"><div class="algolia-stats"></div><div class="algolia-poweredBy"></div></div></div></div></div><div id="search-mask"></div></div><div id="rightMenu"><div class="rightMenu-group rightMenu-small"><div class="rightMenu-item" id="menu-backward"><i class="fa-solid fa-arrow-left"></i></div><div class="rightMenu-item" id="menu-forward"><i class="fa-solid fa-arrow-right"></i></div><div class="rightMenu-item" id="menu-refresh"><i class="fa-solid fa-arrow-rotate-right"></i></div><div class="rightMenu-item" id="menu-home"><i class="fa-solid fa-house"></i></div></div><div class="rightMenu-group rightMenu-line rightMenuOther"><a class="rightMenu-item menu-link" href="/archives/"><i class="fa-solid fa-archive"></i><span>文章归档</span></a><a class="rightMenu-item menu-link" href="/categories/"><i class="fa-solid fa-folder-open"></i><span>文章分类</span></a><a class="rightMenu-item menu-link" href="/tags/"><i class="fa-solid fa-tags"></i><span>文章标签</span></a></div><div class="rightMenu-group rightMenu-line rightMenuNormal"><a class="rightMenu-item menu-link" id="menu-radompage" href="/random/index.html"><i class="fa-solid fa-shoe-prints"></i><span>随便逛逛</span></a><div class="rightMenu-item" id="menu-translate"><i class="fa-solid fa-earth-asia"></i><span>繁简切换</span></div><div class="rightMenu-item" id="menu-darkmode"><i class="fa-solid fa-moon"></i><span>切换模式</span></div></div></div><div id="rightmenu-mask"></div><div><script src="/dujie5416/js/utils.js"></script><script src="/dujie5416/js/main.js"></script><script src="/dujie5416/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/algoliasearch/dist/algoliasearch-lite.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instantsearch.js/dist/instantsearch.production.min.js"></script><script src="/dujie5416/js/search/algolia.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>function subtitleType () {
  getScript('https://yijuzhan.com/api/word.php?m=js').then(() => {
    const con = str[0]
    if (true) {
      const from = '出自 ' + str[1]
      const sub = []
      sub.unshift(con, from)
      window.typed = new Typed('#subtitle', {
        strings: sub,
        startDelay: 300,
        typeSpeed: 150,
        loop: true,
        backSpeed: 50,
      })
    } else {
      document.getElementById('subtitle').innerHTML = con
    }
  })
}

if (true) {
  if (typeof Typed === 'function') {
    subtitleType()
  } else {
    getScript('https://cdn.jsdelivr.net/npm/typed.js/lib/typed.min.js').then(subtitleType)
  }
} else {
  subtitleType()
}
</script></div><script defer src="https://npm.elemecdn.com/jquery@latest/dist/jquery.min.js"></script><script data-pjax defer src="https://npm.elemecdn.com/tzy-blog/lib/js/theme/chocolate.js"></script><canvas id="universe"></canvas><script defer src="/js/universe.js"></script><script defer data-pjax src="/js/rightMenu.js"></script><div class="aplayer no-destroy" data-id="7427714271" data-server="netease" data-type="playlist" data-fixed="true" data-mini="true" data-listFolded="false" data-order="random" data-lrctype="1" data-preload="none" data-autoplay="true" muted></div><script id="click-show-text" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/click-show-text.min.js" data-mobile="false" data-text="I,LOVE,YOU" data-fontsize="15px" data-random="false" async="async"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/metingjs/dist/Meting.min.js"></script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = ["meta[property=\"og:image\"]","meta[property=\"og:title\"]","meta[property=\"og:url\"]","head > title","#config-diff","#body-wrap","#rightside-config-hide","#rightside-config-show",".js-pjax"]

var pjax = new Pjax({
  elements: 'a:not([target="_blank"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:send', function () {

  // removeEventListener scroll 
  window.tocScrollFn && window.removeEventListener('scroll', window.tocScrollFn)
  window.scrollCollect && window.removeEventListener('scroll', scrollCollect)

  typeof preloader === 'object' && preloader.initLoading()
  document.getElementById('rightside').style.cssText = "opacity: ''; transform: ''"
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

  typeof disqusjs === 'object' && disqusjs.destroy()
})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  // google analytics
  typeof gtag === 'function' && gtag('config', '', {'page_path': window.location.pathname});

  // baidu analytics
  typeof _hmt === 'object' && _hmt.push(['_trackPageview',window.location.pathname]);

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start --><script data-pjax>
  function butterfly_clock_anzhiyu_injector_config(){
    var parent_div_git = document.getElementsByClassName('sticky_layout')[0];
    var item_html = '<div class="card-widget card-clock"><div class="card-glass"><div class="card-background"><div class="card-content"><div id="hexo_electric_clock"><img class="entered loading" id="card-clock-loading" src="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/loading.gif" style="height: 120px; width: 100%;" data-ll-status="loading"/></div></div></div></div></div>';
    console.log('已挂载butterfly_clock_anzhiyu')
    if(parent_div_git) {
      parent_div_git.insertAdjacentHTML("afterbegin",item_html)
    }
  }
  var elist = 'null'.split(',');
  var cpage = location.pathname;
  var epage = 'all';
  var qweather_key = '56289903f0d448dfbe8262dba0175f70';
  var gaud_map_key = '01603f2b2d08d0e947bb101e9d9b148b';
  var baidu_ak_key = 'undefined';
  var flag = 0;
  var clock_rectangle = '112.982279,28.19409';
  var clock_default_rectangle_enable = 'false';

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_clock_anzhiyu_injector_config();
  }
  else if (epage === cpage){
    butterfly_clock_anzhiyu_injector_config();
  }
  </script><script src="https://widget.qweather.net/simple/static/js/he-simple-common.js?v=2.0"></script><script data-pjax src="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/clock.min.js"></script><!-- hexo injector body_end end --><script src="/dujie5416/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"tagMode":false,"debug":false,"model":{"jsonPath":"/dujie5416/live2dw/assets/tororo.model.json"},"display":{"position":"right","width":150,"height":350,"hOffset":20,"vOffset":-20},"mobile":{"show":false},"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/"});</script><script async>window.onload=function(){var a=document.createElement('script'),b=document.getElementsByTagName('script')[0];a.type='text/javascript',a.async=!0,a.src='/sw-register.js?v='+Date.now(),b.parentNode.insertBefore(a,b)};</script></body></html>